import { useRef } from 'react';
import { Animated } from 'react-native';

// 点击按钮缩放动画hook
const usePress = () => {
  const scaleValue = useRef(new Animated.Value(1)).current;

  const handlePressIn = () => {
    Animated.timing(scaleValue, {
      toValue: 0.95,
      duration: 100,
      useNativeDriver: true,
    }).start();
  };

  const handlePressOut = () => {
    Animated.timing(scaleValue, {
      toValue: 1,
      duration: 100,
      useNativeDriver: true,
    }).start();
  };

  return { scaleValue, handlePressIn, handlePressOut };
};

export default usePress;
